<?php
	namespace Phone\Controller;
	use Think\Controller;
/**
 * 触屏版  内容页面文章控制器
 */
 class ArticleController extends IsLoginController{
 	/**
	 *文章首页手机调用
	 */
	 public function index(){
	 	
		 	$aid = I('get.aid','0','intval'); 						 					//文章id
			$cid = I('get.cid','0','intval');						 					//栏目id		
			
			$categoryData = M('category')->where("cid='{$cid}'")->find();		//通过cid 查询栏目模型
			$mid = $categoryData['duosute_model_mid'];
			$modelName = M("Model")->where("mid='{$mid}'")->find();
			$defaultTable = $modelName['mdefault_field'];						//默认表明
			$aloneTable = $modelName['mmodel_name'];							//独立表
			//关联表查询数据   //组合查询语句
			$join = ' join duosute_'. $aloneTable . ' on duosute_' .$defaultTable.'.id= duosute_'.$aloneTable.'.aid'; 
			$articleData = M($defaultTable)->JOIN($join)->where("aid = '{$aid}'")->find(); //查询内容
	
			//查询默认表内容
			$articleData = M($defaultTable)->where("id = '{$aid}'")->find(); 
			$selfData =  M($aloneTable)->where("aid = '{$aid}'")->find(); 
			if($selfData){
				foreach($selfData as $k => $v){
					$articleData[$k] = $v;
				}
			}
			
			//时间重组
			$articleData['aauthor'] = 'qianbaidu';//为做查询 赋默认值
			$articleData['aaddtime'] = date('Y-m-d H:i:s',$articleData['aaddtime']);
			$this->assign('articleData',$articleData);
		
		$this->display();
	 }




 }
